//对任何实现了特定的trait 的类型有条件的实现trait

trait GetName{
    fn get_name(&self)->String;
}

trait PrintName{
    fn print_name(&self);
}
impl <T> PrintName for T 
where T:GetName{
    fn print_name(&self){
        println!("name={}",self.get_name())
    }
}

struct Student{
    name:String
}

impl GetName for Student{
    fn get_name(&self)->String{
        format!("{}",self.name)
    }
}


fn main(){
    let s=Student{
        name:"Hello".to_string()
    };
    s.print_name();
}